package com.changgou.order.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.goods.pojo.Sku;
import com.changgou.order.config.TokenDecode;
import com.changgou.order.pojo.Collect;
import com.changgou.order.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/collect")
public class CollectController {

    @Autowired
    private CollectService collectService;

    /**
     * 根据用户名查询收藏的sku商品信息
     *
     * @return
     */
    @GetMapping("/list")
    public Result<List<Collect>> list() {
        TokenDecode tokenDecode = new TokenDecode();
        String username = tokenDecode.getUserInfo().get("user_name");
        List<Collect> collectList = collectService.list(username);
        return new Result<>(true, StatusCode.OK,"查询成功",collectList);
    }
}
